package com.hx.net.c;

import java.net.DatagramPacket;
import java.net.DatagramSocket;

/**
 * @author jxlgcmh
 * @create 2019-05-10 21:37
 */
public class UDPServer {
    public static void main(String[] args) throws Exception {

        DatagramSocket socket = new DatagramSocket(8888);
        byte[] buffer = new byte[100];
        DatagramPacket packet = new DatagramPacket(buffer, 0, buffer.length);

        socket.receive(packet);

        System.out.println(new String(packet.getData(), 0, packet.getLength()));

        socket.close();
    }
}
